<%@page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy"%>
<%@page import="com.oreilly.servlet.MultipartRequest"%>
<%@page import="java.io.File"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	request.setCharacterEncoding("UTF-8");
	String cp = request.getContextPath();
	
	String root = pageContext.getServletContext().getRealPath("/");
	
	String path = root + File.separator + "pds" + File.separator + "saveData";
	File dir = new File(path);
	
	if(!dir.exists())
		dir.mkdirs();
	
	String encType = "UTF-8";
	int maxFileSize = 5*1024*1024;
	
	try{
		MultipartRequest req = 
				new MultipartRequest(request,path,maxFileSize,encType,new DefaultFileRenamePolicy());
		out.print("이름 : " + req.getParameter("name") +"<br/>");
		out.print("서버에 저장된 파일명 : " + req.getFilesystemName("upload")+"<br/>");
		out.print("업로드한 파일명:"+req.getOriginalFileName("upload")+"<br/>");
		out.print("파일 타입"+req.getContentType("upload")+"<br/>");
		
		File f = req.getFile("upload");
		if(f != null)
			out.print("파일 길이"+f.length()+"<br/>");
	}catch(Exception e){
		e.printStackTrace();
	}
%>